/*
 * Copyright (c) 2010-2025 Haifeng Li. All rights reserved.
 *
 * Smile is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Smile is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Smile. If not, see <https://www.gnu.org/licenses/>.
 */
package smile.interpolation;

import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;

/**
 *
 * @author Haifeng Li
 */
public class KrigingInterpolation2DTest {

    private final double[][] data = {
            {7.5,   25.725225,   -82.013512},
            {6.0,   25.725225,   -82.00901},
            {4.875,   25.725225,   -82.0},
            {0.0,   25.725225,   -81.968468},
            {1.0,   25.725225,   -81.963966},
            {5.0,   25.725225,   -81.954956},
            {6.5,   25.725225,   -81.945946},
            {3.0,   25.725225,   -81.941444},
            {1.5,   25.725225,   -81.88739},
            {5.875,   25.729731,   -82.013512},
            {8.0,   25.729731,   -82.0},
            {2.5,   25.729731,   -81.909912},
            {1.5,   25.729731,   -81.810814},
            {6.0,   25.734234,   -82.013512},
            {0.5,   25.734234,   -81.909912},
            {2.5,   25.734234,   -81.810814},
            {6.0,   25.734234,   -81.770271},
            {4.75,   25.734234,   -81.765762},
            {5.0,   25.738739,   -82.004501},
            {6.25,   25.738739,   -81.801804},
            {4.5,   25.743244,   -82.004501},
            {2.5,   25.743244,   -81.801804},
            {5.5,   25.743244,   -81.729729},
            {3.25,   25.747747,   -81.891891},
            {6.5,   25.747747,   -81.779282},
            {5.0,   25.747747,   -81.774773},
            {0.5,   25.752253,   -81.846848},
            {0.5,   25.756756,   -81.986488},
            {2.0,   25.756756,   -81.963966},
            {2.0,   25.756756,   -81.959457},
            {2.5,   25.756756,   -81.846848},
            {9.0,   25.756756,   -81.783783},
            {4.75,   25.756756,   -81.779282},
            {2.5,   25.756756,   -81.774773},
            {2.0,   25.761261,   -81.986488},
            {5.0,   25.761261,   -81.963966},
            {5.0,   25.761261,   -81.959457},
            {10.5,   25.761261,   -81.783783},
            {3.5,   25.761261,   -81.729729},
            {3.5,   25.765766,   -82.00901},
            {3.5,   25.765766,   -81.873871},
            {9.5,   25.765766,   -81.86937},
            {4.166667,   25.765766,   -81.729729},
            {4.0,   25.770269,   -81.882881},
            {8.5,   25.770269,   -81.87838},
            {4.0,   25.770269,   -81.86937},
            {6.5,   25.770269,   -81.779282},
            {4.5,   25.770269,   -81.774773},
            {5.0,   25.774775,   -82.0},
            {7.5,   25.774775,   -81.873871},
            {7.5,   25.774775,   -81.86937},
            {2.0,   25.77928,   -82.0},
            {2.75,   25.788288,   -81.779282},
            {6.0,   25.792793,   -81.900902},
            {6.75,   25.792793,   -81.896393},
            {3.833333,   25.797297,   -81.981979},
            {10.5,   25.797297,   -81.981979},
            {6.0,   25.797297,   -81.900902},
            {5.5,   25.806307,   -81.950447},
            {4.833333,   25.806307,   -81.945946},
            {2.0,   25.81081,   -81.950447},
            {3.5,   25.81081,   -81.842339},
            {8.0,   25.81081,   -81.837837},
            {1.0,   25.815315,   -81.792793},
            {1.0,   25.81982,   -81.797295},
            {1.0,   25.81982,   -81.792793},
            {3.5,   25.824324,   -81.774773},
            {3.5,   25.824324,   -81.770271},
            {3.5,   25.828829,   -81.995499},
            {7.375,   25.828829,   -81.99099},
            {4.5,   25.833334,   -81.995499},
            {4.5,   25.833334,   -81.828827},
            {1.0,   25.837837,   -81.99099},
            {3.0,   25.837837,   -81.747749},
            {4.0,   25.842342,   -81.99099},
            {6.0,   25.842342,   -81.828827},
            {7.0,   25.842342,   -81.824326},
            {5.75,   25.842342,   -81.797295},
            {1.25,   25.842342,   -81.747749},
            {2.625,   25.851351,   -81.945946},
            {3.5,   25.851351,   -81.761261},
            {7.0,   25.855856,   -81.945946},
            {4.0,   25.855856,   -81.797295},
            {6.5,   25.855856,   -81.761261},
            {1.75,   25.860361,   -81.945946},
            {2.5,   25.860361,   -81.797295},
            {3.0,   25.860361,   -81.788292},
            {5.0,   25.860361,   -81.783783},
            {4.5,   25.878378,   -81.963966},
            {4.5,   25.882883,   -81.810814},
            {9.5,   25.887388,   -81.810814},
            {7.25,   25.887388,   -81.788292},
            {5.0,   25.887388,   -81.774773},
            {5.0,   25.887388,   -81.747749},
            {2.5,   25.887388,   -81.74324},
            {1.5,   25.891891,   -81.788292},
            {7.0,   25.891891,   -81.774773},
            {3.8,   25.896397,   -81.74324},
            {1.5,   25.896397,   -81.738739},
            {4.75,   25.914415,   -81.788292},
            {7.5,   25.914415,   -81.783783},
            {3.75,   25.914415,   -81.770271},
            {3.5,   25.941441,   -81.842339},
            {3.0,   25.950451,   -81.950447},
            {5.5,   25.950451,   -81.945946},
            {3.0,   25.954954,   -81.86937},
            {5.0,   25.959459,   -81.873871},
            {5.0,   25.959459,   -81.86937},
            {2.75,   25.972973,   -81.774773},
            {8.5,   25.981981,   -81.779282},
            {4.0,   25.986486,   -81.779282},
            {6.0,   26.004505,   -81.819817},
            {5.0,   26.004505,   -79.815315}
    };

    public KrigingInterpolation2DTest() {
    }

    @BeforeAll
    public static void setUpClass() throws Exception {
    }

    @AfterAll
    public static void tearDownClass() throws Exception {
    }

    @BeforeEach
    public void setUp() {
    }

    @AfterEach
    public void tearDown() {
    }

    @Test
    public void testInterpolate() {
        System.out.println("interpolate");

        int n = data.length;
        double[] lat = new double[n];
        double[] lon = new double[n];
        double[] y = new double[n];

        for (int i = 0; i < n; i++) {
            y[i] = data[i][0];
            lat[i] = data[i][1];
            lon[i] = data[i][2];
        }

        KrigingInterpolation2D instance = new KrigingInterpolation2D(lat, lon, y, 1.1);
        assertEquals(4.5469676472147835, instance.interpolate(30.699, -85.327), 1E-7);
    }
}